package leetcode_701_800;

import java.util.ArrayList;
import java.util.List;

public class LeeCode_728 {
    public static void main(String[] args) {
        System.out.println(selfDividingNumbers(1, 22));
    }
    private static List<Integer> selfDividingNumbers(int left, int right) {
        List<Integer> ans = new ArrayList<>();
        for (int i = left; i <= right; i++) {
            int t = i;
            boolean flag = true;
            while (t != 0){
                int ge = t % 10;
                if (ge == 0) {
                    flag = false;
                    break;
                }
                t /= 10;
                if (i % ge != 0){
                    flag = false;
                    break;
                }
            }
            if (flag)
                ans.add(i);
        }
        return ans;
    }
}
